package com.yaha.controler;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.widget.TextView;

import com.yaha.controler.devices.search.DeviceSearchService;
import com.yaha.controler.utils.ApplicationInfoUtil;

/**
 * <功能描述>
 * 
 * @author Frewen.W/909091
 * @version [版本号, 2015-4-8]
 * @since [产品/模块版本]
 */
public class SplashActivity extends BaseActivity {

	private final static int WAIT_TIME = 2500;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		setContentView(R.layout.activity_splash);

		TextView appVersion = (TextView) findViewById(R.id.splash_app_version);
		String versionName = " V" + ApplicationInfoUtil.getVerName(this) + "." + ApplicationInfoUtil.getVerCode(this);
		appVersion.setText(versionName);

	}

	@Override
	protected void onStart() {
		super.onStart();

		// 设备发现服务
		startService(new Intent(this, DeviceSearchService.class));

		new Handler().postDelayed(new Runnable() {
			public void run() {
				redirectTo();
			}
		}, WAIT_TIME);
	}

	private void redirectTo() {
		Intent mIntent = new Intent(this, MainActivity.class);
		startActivity(mIntent);
		this.finish();
	}

}
